/**2012-4-14**/

package com.cq.arith;

/**
 * kmp�㷨������ʵ��
 * 
 * @author ��ǿ
 * @since 1.0
 * @version 2012-4-14 ��ǿ�½�
 */
public class MyKmp {
    
    int pos = -1;
    
    int count = 0;
    
    public void stringKmp(String src, String des) {
        if (null == src || null == des)
            return;
        if (src.length() == 0 || des.length() == 0)
            return;
        char[] s = src.length() > des.length() ? src.toCharArray() : des.toCharArray();
        char[] d = src.length() < des.length() ? src.toCharArray() : des.toCharArray();
        int iSlen = s.length;
        int iDlen = d.length;
        int temp;
        int flag1, flag2;
        char[] ch;
        for (int i = 0; i < iSlen;) {
            if (i + iDlen > iSlen)
                break;
            ch = new char[iDlen];
            for (temp = 0; temp < iDlen; temp++) {
                if (s[i + temp] != d[temp])
                    break;
                // �����,ch�м�¼��ƥ�������
                ch[temp] = d[temp];
            }
            if (pos == -1 && temp == iDlen) {
                this.pos = i;// ��¼��һ�μ�¼���ֵ�λ��
            }
        }
    }
    
    private static int[] analysePos(char[] ch) {
        if (null == ch)
            return null;
        int[] cour = new int[ch.length];
        return null;
    }
}
